#pragma once

#include "Infra/Function.h"
#include "GenICam/AcquisitionControl.h"
#include "GenICam/AnalogControl.h"
#include "GenICam/ImageFormatControl.h"
#include "GenICam/ISPControl.h"
#include <sstream>
#include <map>

#define EDIT_CHANGE   0
#define SLIDER_CHANGE 1

enum EAttrIdx
{
	SATURATION = 0,
	FRAMERATE  = 1,
	EXPOSURETIME = 2,
	GAINRAW = 3,
	GAMMA = 4,
	BRIGHTNESS = 5,
	SHARPNESS = 6,
	HUE = 7,
	WHITEBALANCE_R = 8,
	WHITEBALANCE_G = 9,
	WHITEBALANCE_B = 10,
	PICFORMAT = 11,
	AUTOEXPOSURE = 12,
	EXPOSUREMODE = 13,
	GAINAUTO = 14,
	BLACKLEVEL = 15,
	PLAYMODE = 16,
	REVERSEX = 17,
	REVERSEY = 18,
	TRIGGERMODE = 19,
	SOFTTRIGGER = 20,
	MUTIFRAMECNT = 21
};

// xml Item值
struct XmlCfgItem
{
	std::string name;
	std::string value;
};

// 属性控件基类
// property control base class
class IAttrCtrlBase
{
public:
	
	// 属性控件初始化
	// property control initialization
	virtual void init(Dahua::GenICam::ICameraPtr& camera) = 0;
	
	// 获取窗口对象，用于Edit控件回车响应
	// gets the window object used to edit the control's enter  response
	virtual CWnd* getWnd() = 0;
	
	// 更新自身的状态
	// update own status
	virtual void updataStatus(Dahua::GenICam::ICameraPtr& camera) {}
	
	// 更新属性参数
	// Update property parameters
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, int param) = 0;
	
	// 导入属性参数
	// import property parameters
	void readCfg(Dahua::GenICam::ICameraPtr& camera, std::vector< XmlCfgItem >& itemVec) 
	{
		std::vector< XmlCfgItem >::iterator it = itemVec.begin();
		for (; it != itemVec.end(); ++it)
		{
			if ((*it).name == getAttrName())
			{
				updataValue(camera, (*it).value);
			}
		}
	}
	
	// 导出属性参数
	// export property parameters
	virtual void writeCfg(Dahua::GenICam::ICameraPtr& camera, std::vector< XmlCfgItem >& itemVec) = 0;
	
	// 虚析构
	//virtual deconstructor function
	virtual ~IAttrCtrlBase() {}
	
protected:
	
	// 获取属性名称
	// get property name
	virtual std::string getAttrName() = 0;
	
	// 更新属性参数
	// update property parameters
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, std::string const& val) = 0;

};

// 下拉框空间基类
// drop down box space base class
class CComBoxAttrBase : public IAttrCtrlBase
{
public:
	
	// 选项更改后的联动函数   | linkage function after option change
	// \param[in] CWnd*                      控件所属的窗口句柄 | The window handle to which the control belongs
	// \param[in] Dahua::GenICam::ICameraPtr 相机对象 | camera object
	// \return    void
	typedef Dahua::Infra::TFunction2<void, CWnd*, Dahua::GenICam::ICameraPtr&> SelectProc;
	
	// 构造函数  | construct function
	// \param[in] hwd     控件所属的窗口句柄  | the window handle to which the control belongs
	// \param[in] IDC_ID  控件ID    |control ID
	CComBoxAttrBase(CWnd* hwd, int IDC_ID)
		: _wnd(hwd) 
		, _ctrl((CComboBox *)hwd->GetDlgItem(IDC_ID))
	{
	}
	
	// 设置更改联动动作  | set change linkage action
	void setSelectProc(std::map<std::string, SelectProc> selectProc)
	{
		_selectProc = selectProc;
	}
	
	// 更改数值 | modify value
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, int param)
	{
		int selectInt = _ctrl->GetCurSel();
		ASSERT(selectInt < (int)_stringVec.size());
		std::string selectedStr = _stringVec[selectInt];
		
		setValue(camera, selectedStr);
	}
	
	// 初始化控件 | inilazition control
	virtual void init(Dahua::GenICam::ICameraPtr& camera)
	{
		_ctrl->ResetContent();
		
		Dahua::GenICam::CEnumNode value = getEnumNodePtr(camera);
		if (!value.isValid())
		{
			_ctrl->EnableWindow(FALSE);
			return;
		}

		Dahua::Infra::TVector<Dahua::Infra::CString> vec = value.getEnumSymbolList();
		Dahua::Infra::CString cur;
		value.getValueSymbol(cur);
		
		_stringVec.clear();
		int curIdx = 0, i = 0;
		Dahua::Infra::TVector<Dahua::Infra::CString>::iterator it = vec.begin();
		for (; it != vec.end(); ++it, ++i)
		{
			if ((*it) == cur)
			{
				curIdx = i;
			}
			_stringVec.push_back((*it).c_str());
			_ctrl->InsertString(i, (*it).c_str());
		}
		
		std::map<std::string, SelectProc>::iterator iter = _selectProc.find(cur.c_str());
		if (iter != _selectProc.end() && iter->second)
		{
			iter->second(_wnd, camera);
		}
		
		_ctrl->SetCurSel(curIdx);
	}

	// 更新自身的状态
	// Update own status
	virtual void updataStatus(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::CEnumNode value = getEnumNodePtr(camera);
		if (!value.isValid())
			return;
		
		if (!value.isWriteable())
		{
			_ctrl->EnableWindow(FALSE);
		}
		else
		{
			_ctrl->EnableWindow(TRUE);
		}
	}
	
	// 获取Edit句柄
	// get edit handle
	virtual CWnd* getWnd()
	{
		return NULL;
	}
	
protected:
	
	// 更新属性参数
	//Update property parameters
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, std::string const& strVal)
	{
		setValue(camera, strVal);
	}
	
	// 导出属性参数
	// import property parameters
	virtual void writeCfg(Dahua::GenICam::ICameraPtr& camera, std::vector< XmlCfgItem >& itemVec)
	{
		Dahua::GenICam::CEnumNode value = getEnumNodePtr(camera);
		if (!value.isValid())
			return;
		
		XmlCfgItem item;
		item.name = getAttrName();
		
		Dahua::Infra::CString val;
		value.getValueSymbol(val);
		item.value = val.c_str();
		
		itemVec.push_back(item);
	}
	
	// 设置参数
	//set parameters
	void setValue(Dahua::GenICam::ICameraPtr& camera, std::string selectedStr)
	{
		std::map<std::string, SelectProc>::iterator it = _selectProc.find(selectedStr);
		if (it != _selectProc.end() && it->second)
		{
			it->second(_wnd, camera);
		}
		
		Dahua::GenICam::CEnumNode value = getEnumNodePtr(camera);
		if (!value.isValid())
			return;

		if (value.isWriteable() && !value.setValueBySymbol(selectedStr.c_str()))
		{
			_wnd->MessageBox("Set Value Failed.", "", 0);
			_wnd->MessageBox(getAttrName().c_str(), "", 0);
		}
	}
	
	virtual Dahua::GenICam::CEnumNode getEnumNodePtr(Dahua::GenICam::ICameraPtr& camera) = 0;
	
	CWnd*                             _wnd;
	CComboBox*                        _ctrl;
	std::vector<std::string>          _stringVec;   // 下来框的字符组合 | character combination of the lower box
	std::map<std::string, SelectProc> _selectProc;  // 选择不同字符时的回调函数集合 | Collection of callback functions when selecting different characters
};


// 该类是滑动条与文本框结合的控件类抽象 | this class is the control class abstraction of the combination of slider and text box
template<typename ValType,         // 参数类型 | Parameter type
		 typename R,               // GenICam定义的参数节点类型 如 IIntNode | Parameter node type defined by genicam eg:IIntNode
		 typename GetValueMethod,  // 获取参数节点的方法 GetValueMethod::getValuePtr(Dahua::GenICam::ICameraPtr& camera) | get parameter nodes method
		 int SliderID,             // 滑动条的IDC_ID | Slider bar IDC_ID
		 int EditID                // 文本框的IDC_ID | context  IDC_ID
		>
class TSliderEditAttr : public IAttrCtrlBase
{
public:
	
	// 构造函数 |construct function 
	// \param[in] hwd控件所属的窗口类指针 | window class pointer to which HWD control belongs
	TSliderEditAttr(CWnd* hwd)
	{
		_sliderCtrl = (CSliderCtrl *)hwd->GetDlgItem(SliderID);
		_editCtrl = (CEdit *)hwd->GetDlgItem(EditID);
	}
	
	// 虚析构函数 | desconstructor virtual function
	virtual ~TSliderEditAttr() {}
	
	// 继承IAttrCtrlBase的初始化接口
	// Inherit the initialization interface of IAttrCtrlBase
	virtual void init(Dahua::GenICam::ICameraPtr& camera)
	{
		if (NULL == camera)
			return;
		
		// 获取参数节点
		// get parameter node
		R valuePtr = GetValueMethod::getValuePtr(camera);
		if (!valuePtr.isValid())
		{
			_editCtrl->EnableWindow(FALSE);
			_sliderCtrl->EnableWindow(FALSE);
			return;
		}
		
		// 获取最大，最小值以及当前值
		//get the maximum, minimum, and current values
		ValType max, min, val;
		valuePtr.getMaxVal(max);
		valuePtr.getMinVal(min);
		valuePtr.getValue(val);
		_val = val;
		
		// 初始化滑动条与文本框
		// Initialize sliders and text boxes
		_sliderCtrl->SetRange((int)min, (int)max);
		_sliderCtrl->SetPos((int)val);
		
		std::stringstream ss;
		ss << val;
		_editCtrl->SetWindowText(ss.str().c_str());
	}
	
	// 更新数据两个地方调用 1、滑动条变化 2、编辑窗口收到回车事件
	// Two places to update the data call 1. The slider changes 2. The editing window receives Enter event
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, int type)
	{
		TSliderEditAttr::setValue(camera, type != 0);
	}
	
	// 更新自身的状态
	// Update own status
	virtual void updataStatus(Dahua::GenICam::ICameraPtr& camera)
	{
		R value = GetValueMethod::getValuePtr(camera);
		if (!value.isValid())
			return;
		
		if (!value.isWriteable())
		{
			_editCtrl->EnableWindow(FALSE);
			_sliderCtrl->EnableWindow(FALSE);
		}
		else
		{
			_editCtrl->EnableWindow(TRUE);
			_sliderCtrl->EnableWindow(TRUE);
		}
	}

	// 导出属性参数
	// import property parameters
	virtual void writeCfg(Dahua::GenICam::ICameraPtr& camera, std::vector< XmlCfgItem >& itemVec)
	{
		R value = GetValueMethod::getValuePtr(camera);
		if (!value.isValid())
			return;

		XmlCfgItem item;
		item.name = getAttrName();
		
		ValType val;
		value.getValue(val);
		std::stringstream ss;
		ss << val;
		item.value = ss.str();
		
		itemVec.push_back(item);
	}
	
	// 更新属性参数，用于xml文件的参数更新
	// Update attribute parameters for parameter update of XML file
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, std::string const& strVal)
	{
		ValType val;
		std::stringstream ss;
		ss << strVal;
		ss >> val;
		
		syncValue(camera, val);
	}
	
	// 设置数值
	//set value
	void setValue(Dahua::GenICam::ICameraPtr& camera, bool slider = true)
	{
		if (NULL == camera)
			return;
		
		ValType val;
		if (slider)
		{
			val = (ValType)_sliderCtrl->GetPos();
		}
		else
		{
			::CString text;
			_editCtrl->GetWindowText(text);
			std::stringstream ss;
			ss << text;
			ss >> val;
		}
		
		syncValue(camera, val);
	}
	
	// 获取窗口对象，用于Edit控件回车响应
	// gets the window object used to edit the control's Enter response
	virtual CWnd* getWnd()
	{
		return (CWnd*)_editCtrl;
	}
	
protected:
	
	void syncValue(Dahua::GenICam::ICameraPtr& camera, ValType val)
	{
		R value = GetValueMethod::getValuePtr(camera);
		if (!value.isValid())
			return;
		
		if (_val != val && value.isWriteable())
		{
			_val = val;
			value.setValue(val);
		}

		std::stringstream ss;
		ss << _val;
		_editCtrl->SetWindowText(ss.str().c_str());
		_sliderCtrl->SetPos((int)_val);
	}
	
	CSliderCtrl* _sliderCtrl;
	CEdit*       _editCtrl;
	ValType      _val;
};

typedef Dahua::Memory::TSharedPtr<IAttrCtrlBase> AttrCtrlBasePtr;
typedef std::map< int, AttrCtrlBasePtr > AttrCtrlMap;

struct SaturationAttr
	: public TSliderEditAttr<int64_t, Dahua::GenICam::CIntNode, SaturationAttr, IDC_SLIDER_SATURATION, IDC_EDIT_SATURATION>
{
	typedef TSliderEditAttr<int64_t, Dahua::GenICam::CIntNode, SaturationAttr, IDC_SLIDER_SATURATION, IDC_EDIT_SATURATION> base_type;

	SaturationAttr(CWnd* wnd)
		: base_type(wnd)
	{}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "Saturation";
	}

	static Dahua::GenICam::CIntNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IISPControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createISPControl(camera);
		return ptr->saturation();
	}
};

struct FrameRateAttr
	: public TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, FrameRateAttr, IDC_SLIDER_FRAMERATE, IDC_EDIT_FRAMERATE>
{
	typedef TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, FrameRateAttr, IDC_SLIDER_FRAMERATE, IDC_EDIT_FRAMERATE> base_type;

	FrameRateAttr(CWnd* wnd)
		: base_type(wnd)
	{}

	static Dahua::GenICam::CDoubleNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		return ptr->acquisitionFrameRate();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "AcquisitionFrameRate";
	}
};

struct ExposureTimeAttr
	: public TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, ExposureTimeAttr, IDC_SLIDER_EXPOSURETIME, IDC_EDIT_EXPOSURETIME>
{
	typedef TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, ExposureTimeAttr, IDC_SLIDER_EXPOSURETIME, IDC_EDIT_EXPOSURETIME> base_type;

	ExposureTimeAttr(CWnd* wnd)
		: base_type(wnd)
	{}
	
	static Dahua::GenICam::CDoubleNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		return ptr->exposureTime();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "ExposureTime";
	}
};

struct GainRawAttr
	: public TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, GainRawAttr, IDC_SLIDER_GAIN, IDC_EDIT_GAIN>
{
	typedef TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, GainRawAttr, IDC_SLIDER_GAIN, IDC_EDIT_GAIN> base_type;
	
	GainRawAttr(CWnd* wnd)
		: base_type(wnd)
	{}
	
	static Dahua::GenICam::CDoubleNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAnalogControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAnalogControl(camera);
		return ptr->gainRaw();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "GainRaw";
	}
};

struct GammaAttr
	: public TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, GammaAttr, IDC_SLIDER_GAMA, IDC_EDIT_GAMA>
{
	typedef TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, GammaAttr, IDC_SLIDER_GAMA, IDC_EDIT_GAMA> base_type;

	GammaAttr(CWnd* wnd)
		: base_type(wnd)
	{}

	static Dahua::GenICam::CDoubleNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAnalogControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAnalogControl(camera);
		return ptr->gamma();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "Gamma";
	}
};

struct BrightnessAttr
	: public TSliderEditAttr<int64_t, Dahua::GenICam::CIntNode, BrightnessAttr, IDC_SLIDER_LIGHT, IDC_EDIT_LIGHT>
{
	typedef TSliderEditAttr<int64_t, Dahua::GenICam::CIntNode, BrightnessAttr, IDC_SLIDER_LIGHT, IDC_EDIT_LIGHT> base_type;

	BrightnessAttr(CWnd* wnd)
		: base_type(wnd)
	{}
	
	static Dahua::GenICam::CIntNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IISPControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createISPControl(camera);
		return ptr->brightness();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "Brightness";
	}
};

struct SharpnessAttr
	: public TSliderEditAttr<int64_t, Dahua::GenICam::CIntNode, SharpnessAttr, IDC_SLIDER_SHARPNESS, IDC_EDIT_SHARPNESS>
{
	typedef TSliderEditAttr<int64_t, Dahua::GenICam::CIntNode, SharpnessAttr, IDC_SLIDER_SHARPNESS, IDC_EDIT_SHARPNESS> base_type;

	SharpnessAttr(CWnd* wnd)
		: base_type(wnd)
	{}

	static Dahua::GenICam::CIntNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IISPControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createISPControl(camera);
		return ptr->sharpness();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "Sharpness";
	}
};

struct HueAttr
	: public TSliderEditAttr<int64_t, Dahua::GenICam::CIntNode, HueAttr, IDC_SLIDER_HUE, IDC_EDIT_HUE>
{
	typedef TSliderEditAttr<int64_t, Dahua::GenICam::CIntNode, HueAttr, IDC_SLIDER_HUE, IDC_EDIT_HUE> base_type;
	
	HueAttr(CWnd* wnd)
		: base_type(wnd)
	{}
	
	static Dahua::GenICam::CIntNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IISPControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createISPControl(camera);
		return ptr->hue();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "Hue";
	}
};

struct WhiteBalanceR
	: public TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, WhiteBalanceR, IDC_SLIDER_RWHITEBALANCE, IDC_EDIT_RWHITEBALANCE>
{
	typedef TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, WhiteBalanceR, IDC_SLIDER_RWHITEBALANCE, IDC_EDIT_RWHITEBALANCE> base_type;
	
	WhiteBalanceR(CWnd* wnd)
		: base_type(wnd)
	{}
	
	static Dahua::GenICam::CDoubleNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAnalogControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAnalogControl(camera);
		
		Dahua::GenICam::CEnumNode val = ptr->balanceRatioSelector();
		if ( val.isValid() )
		{
			val.setValueBySymbol("Red");
		}
		return ptr->balanceRatio();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "WhiteBalance_Red";
	}
};

struct WhiteBalanceG
	: public TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, WhiteBalanceG, IDC_SLIDER_GWHITEBALANCE, IDC_EDIT_GWHITEBALANCE>
{
	typedef TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, WhiteBalanceG, IDC_SLIDER_GWHITEBALANCE, IDC_EDIT_GWHITEBALANCE> base_type;

	WhiteBalanceG(CWnd* wnd)
		: base_type(wnd)
	{}
	
	static Dahua::GenICam::CDoubleNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAnalogControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAnalogControl(camera);
		
		Dahua::GenICam::CEnumNode val = ptr->balanceRatioSelector();
		if ( val.isValid() )
		{
			val.setValueBySymbol("Green");
		}
		return ptr->balanceRatio();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "WhiteBalance_Green";
	}
};

struct WhiteBalanceB
	: public TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, WhiteBalanceB, IDC_SLIDER_BWHITEBALANCE, IDC_EDIT__BWHITEBALANCE>
{
	typedef TSliderEditAttr<double, Dahua::GenICam::CDoubleNode, WhiteBalanceB, IDC_SLIDER_BWHITEBALANCE, IDC_EDIT__BWHITEBALANCE> base_type;
	
	WhiteBalanceB(CWnd* wnd)
		: base_type(wnd)
	{}
	
	static Dahua::GenICam::CDoubleNode getValuePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAnalogControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAnalogControl(camera);

		Dahua::GenICam::CEnumNode val = ptr->balanceRatioSelector();
		
		if ( val.isValid() )
		{
			val.setValueBySymbol("Blue");
		}
		return ptr->balanceRatio();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "WhiteBalance_Blue";
	}
};

class CPictureFormatAttr : public CComBoxAttrBase
{
public:
	
	CPictureFormatAttr(CWnd* wnd)
		: CComBoxAttrBase(wnd, IDC_COMBO_FORMAT)
	{}
	
	virtual Dahua::GenICam::CEnumNode getEnumNodePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		return ptr->pixelFormat();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "PixelFormat";
	}
};

class CAutoExposureAttr : public CComBoxAttrBase
{
public:

	void handleOffMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		wnd->GetDlgItem(IDC_SLIDER_EXPOSURETIME)->EnableWindow(FALSE);
		wnd->GetDlgItem(IDC_EDIT_EXPOSURETIME)->EnableWindow(FALSE);;
	}

	void handleOnMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		wnd->GetDlgItem(IDC_SLIDER_EXPOSURETIME)->EnableWindow(TRUE);
		wnd->GetDlgItem(IDC_EDIT_EXPOSURETIME)->EnableWindow(TRUE);;
	}
	
	CAutoExposureAttr(CWnd* wnd)
		: CComBoxAttrBase(wnd, IDC_COMBO_AUTOEXPOSURE)
	{
		std::map<std::string, SelectProc> selectMap;
		selectMap["Off"] = SelectProc(&CAutoExposureAttr::handleOnMode, this);
		selectMap["Once"] = SelectProc(&CAutoExposureAttr::handleOffMode, this);
		selectMap["Continuous"] = SelectProc(&CAutoExposureAttr::handleOffMode, this);
		
		setSelectProc(selectMap);
	}
	
	virtual Dahua::GenICam::CEnumNode getEnumNodePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		return ptr->exposureAuto();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "ExposureAuto";
	}
};

class CExposureModeAttr : public CComBoxAttrBase
{
public:

	CExposureModeAttr(CWnd* wnd)
		: CComBoxAttrBase(wnd, IDC_COMBO_EXPOSUREMODE)
	{
	}
	
	virtual Dahua::GenICam::CEnumNode getEnumNodePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		return ptr->exposureMode();
	}
	
	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "ExposureMode";
	}
};

class CAutoGainAttr : public CComBoxAttrBase
{
public:

	void handleOffMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		wnd->GetDlgItem(IDC_SLIDER_GAIN)->EnableWindow(FALSE);
		wnd->GetDlgItem(IDC_EDIT_GAIN)->EnableWindow(FALSE);;
	}

	void handleOnMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		wnd->GetDlgItem(IDC_SLIDER_GAIN)->EnableWindow(TRUE);
		wnd->GetDlgItem(IDC_EDIT_GAIN)->EnableWindow(TRUE);;
	}

	CAutoGainAttr(CWnd* wnd)
		: CComBoxAttrBase(wnd, IDC_COMBO_AUTOGAIN)
	{
		std::map<std::string, SelectProc> selectMap;
		selectMap["Off"] = SelectProc(&CAutoGainAttr::handleOnMode, this);
		selectMap["Once"] = SelectProc(&CAutoGainAttr::handleOffMode, this);
		selectMap["Continuous"] = SelectProc(&CAutoGainAttr::handleOffMode, this);

		setSelectProc(selectMap);
	}
	
	virtual Dahua::GenICam::CEnumNode getEnumNodePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAnalogControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAnalogControl(camera);
		return ptr->gainAuto();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "GainAuto";
	}
};

class CWhitBalanceAttr : public CComBoxAttrBase
{
public:
	
	void handleOffMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		wnd->GetDlgItem(IDC_SLIDER_RWHITEBALANCE)->EnableWindow(FALSE);
		wnd->GetDlgItem(IDC_SLIDER_BWHITEBALANCE)->EnableWindow(FALSE);
		wnd->GetDlgItem(IDC_SLIDER_GWHITEBALANCE)->EnableWindow(FALSE);
		wnd->GetDlgItem(IDC_EDIT_RWHITEBALANCE)->EnableWindow(FALSE);
		wnd->GetDlgItem(IDC_EDIT__BWHITEBALANCE)->EnableWindow(FALSE);
		wnd->GetDlgItem(IDC_EDIT_GWHITEBALANCE)->EnableWindow(FALSE);
	}
	
	void handleOnMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		wnd->GetDlgItem(IDC_SLIDER_RWHITEBALANCE)->EnableWindow(TRUE);
		wnd->GetDlgItem(IDC_SLIDER_BWHITEBALANCE)->EnableWindow(TRUE);
		wnd->GetDlgItem(IDC_SLIDER_GWHITEBALANCE)->EnableWindow(TRUE);
		wnd->GetDlgItem(IDC_EDIT_RWHITEBALANCE)->EnableWindow(TRUE);
		wnd->GetDlgItem(IDC_EDIT__BWHITEBALANCE)->EnableWindow(TRUE);
		wnd->GetDlgItem(IDC_EDIT_GWHITEBALANCE)->EnableWindow(TRUE);
	}
	
	CWhitBalanceAttr(CWnd* wnd)
		: CComBoxAttrBase(wnd, IDC_COMBO_AUTOWHITEBALANCE)
	{
		std::map<std::string, SelectProc> selectMap;
		selectMap["Off"] = SelectProc(&CWhitBalanceAttr::handleOnMode, this);
		selectMap["Once"] = SelectProc(&CWhitBalanceAttr::handleOffMode, this);
		selectMap["Continuous"] = SelectProc(&CWhitBalanceAttr::handleOffMode, this);
		
		setSelectProc(selectMap);
	}
	
	virtual Dahua::GenICam::CEnumNode getEnumNodePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAnalogControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAnalogControl(camera);
		
		return ptr->balanceWhiteAuto();
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "BalanceWhiteAuto";
	}
};

class CAcquisitionModeAttr : public CComBoxAttrBase
{
public:

	CAcquisitionModeAttr(CWnd* wnd, bool& frameLimit, int& cntMax, int& frameCnt)
		: CComBoxAttrBase(wnd, IDC_COMBO_PLAYMODE)
		, _frameLimit(frameLimit)
		, _cntMax(cntMax)
		, _frameCnt(frameCnt)
	{
		std::map<std::string, SelectProc> selectMap;
		selectMap["SingleFrame"] = SelectProc(&CAcquisitionModeAttr::handleSingleFrameMode, this);
		selectMap["MultiFrame"] = SelectProc(&CAcquisitionModeAttr::handleMultiFrameMode, this);
		selectMap["Continuous"] = SelectProc(&CAcquisitionModeAttr::handleConinueFrameMode, this);

		setSelectProc(selectMap);
	}
	
	void handleSingleFrameMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		_frameLimit = true;
		_cntMax = 1;
		_frameCnt = 0;
	}
	
	void handleMultiFrameMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		Dahua::GenICam::CIntNode nodePtr = ptr->acquisitionFrameCount();
		int64_t val;
		if (!nodePtr.isValid())
		{
			return;
		}
		nodePtr.getValue(val);
		
		_frameLimit = true;
		_cntMax = (int)val;
		_frameCnt = 0;
	}
	
	void handleConinueFrameMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		_frameLimit = false;
	}
	
	virtual Dahua::GenICam::CEnumNode getEnumNodePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		return ptr->acquisitionMode();
	}
	
	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "AcquisitionMode";
	}
	
	bool& _frameLimit;
	int&  _cntMax;
	int&  _frameCnt;
};

class CTriggerModeAttr : public CComBoxAttrBase
{
public:

	void handleOffMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		wnd->GetDlgItem(IDC_BTN_SOFTTRIGGER)->EnableWindow(FALSE);

		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		// 关闭 AcquisitionStart
		// close AcquisitionStart
		Dahua::GenICam::CEnumNode valPtr = ptr->triggerSelector();
		if (!valPtr.isValid())
		{
			return;
		}

		valPtr.setValueBySymbol("AcquisitionStart");
		valPtr = ptr->triggerMode();
		if (!valPtr.isValid())
		{
			return;
		}
		valPtr.setValueBySymbol("Off");
		// 关闭 FrameStart
		// close FrameStart
		valPtr = ptr->triggerSelector();
		if (!valPtr.isValid())
		{
			return;
		}
		valPtr.setValueBySymbol("FrameStart");
		
		valPtr = ptr->triggerMode();
		if (!valPtr.isValid())
		{
			return;
		}
		valPtr.setValueBySymbol("Off");
	}

	void handleOnMode(CWnd* wnd, Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		Dahua::GenICam::CEnumNode valPtr = ptr->triggerSource();
		if (!valPtr.isValid())
		{
			return;
		}
		valPtr.setValueBySymbol("Software");
	
#if 0
		// open AcquisitionStart
		valPtr = ptr->triggerSelector();
		if (!valPtr.isValid())
		{
			return;
		}
		valPtr.setValueBySymbol("AcquisitionStart");

		valPtr = ptr->triggerMode();
		if (!valPtr.isValid())
		{
			return;
		}
		valPtr.setValueBySymbol("On");

		Dahua::GenICam::CCmdNode cmd = ptr->triggerSoftware();
		if (!cmd.isValid())
		{
			return;
		}
		cmd.execute();
#endif
		// 打开 FrameStart
		// open FrameStart
		valPtr = ptr->triggerSelector();
		if (!valPtr.isValid())
		{
			return;
		}
		valPtr.setValueBySymbol("FrameStart");

		valPtr = ptr->triggerMode();
		if (!valPtr.isValid())
		{
			return;
		}
		valPtr.setValueBySymbol("On");
		
		wnd->GetDlgItem(IDC_BTN_SOFTTRIGGER)->EnableWindow(TRUE);
	}

	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, int param)
	{
		int selectInt = _ctrl->GetCurSel();
		ASSERT(selectInt < (int)_stringVec.size());
		std::string selectedStr = _stringVec[selectInt];

		std::map<std::string, SelectProc>::iterator it = _selectProc.find(selectedStr);
		if (it != _selectProc.end() && it->second)
		{
			it->second(_wnd, camera);
		}
	}

	virtual void init(Dahua::GenICam::ICameraPtr& camera)
	{
		_ctrl->ResetContent();

		_stringVec.push_back("Off");
		_stringVec.push_back("On");
		_ctrl->InsertString(0,"Off");
		_ctrl->InsertString(1,"On");
		
		std::map<std::string, SelectProc>::iterator iter = _selectProc.find("Off");
		if (iter != _selectProc.end() && iter->second)
		{
			iter->second(_wnd, camera);
		}
		_ctrl->SetCurSel(0);
	}


	CTriggerModeAttr(CWnd* wnd)
		: CComBoxAttrBase(wnd, IDC_COMBO_TRIGGERMODE)
	{
		std::map<std::string, SelectProc> selectMap;
		selectMap["Off"] = SelectProc(&CTriggerModeAttr::handleOffMode, this);
		selectMap["On"] = SelectProc(&CTriggerModeAttr::handleOnMode, this);
		
		setSelectProc(selectMap);
	}
	
	virtual Dahua::GenICam::CEnumNode getEnumNodePtr(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		return ptr->triggerMode();
	}
	
	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "TriggerMode";
	}
};

class CReverseX : public IAttrCtrlBase
{
public:

	CReverseX(CWnd* wnd)
		: _wnd(wnd)
	{}

	void init(Dahua::GenICam::ICameraPtr& camera) 
	{}

	virtual CWnd* getWnd()
	{
		return NULL;
	}

	// 更新自身的状态
	// Update own status
	virtual void updataStatus(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valuePtr = ptr->reverseX();
		if (!valuePtr.isValid())
		{
			return;
		}

		if (!valuePtr.isWriteable())
		{
			_wnd->GetDlgItem(IDC_BTN_HORITRANS)->EnableWindow(FALSE);
		}
		else
		{
			_wnd->GetDlgItem(IDC_BTN_HORITRANS)->EnableWindow(TRUE);
		}
	}
	
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, int param)
	{
		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valPtr = ptr->reverseX();
		
		bool val;
		valPtr.getValue(val);
		valPtr.setValue(!val);
	}

	// 导出属性参数
	// export property parameters
	virtual void writeCfg(Dahua::GenICam::ICameraPtr& camera, std::vector< XmlCfgItem >& itemVec)
	{
		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valPtr = ptr->reverseX();
		
		if (!valPtr.isValid())
		{
			return;
		}
		
		bool val;
		valPtr.getValue(val);

		XmlCfgItem item;
		item.name = getAttrName();
		
		std::stringstream ss;
		ss << val;
		item.value = ss.str();
		
		itemVec.push_back(item);
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "ReverseX";
	}

	// 更新属性参数
	// update property parameters
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, std::string const& strVal)
	{
		bool val;
		std::stringstream ss;
		ss << strVal;
		ss >> val;

		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valPtr = ptr->reverseX();
		if (!valPtr.isValid())
		{
			return;
		}

		valPtr.setValue(val);
	}


	CWnd* _wnd;
};

class CReverseY : public IAttrCtrlBase
{
public:

	CReverseY(CWnd* wnd)
		: _wnd(wnd)
	{}
	
	void init(Dahua::GenICam::ICameraPtr& camera) 
	{}
	
	virtual CWnd* getWnd()
	{
		return NULL;
	}

	// 更新自身的状态
	// Update own status
	virtual void updataStatus(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valuePtr = ptr->reverseY();
		if (!valuePtr.isValid())
		{
			return;
		}

		if (!valuePtr.isWriteable())
		{
			_wnd->GetDlgItem(IDC_BTN_VERTTRANS)->EnableWindow(FALSE);
		}
		else
		{
			_wnd->GetDlgItem(IDC_BTN_VERTTRANS)->EnableWindow(TRUE);
		}
	}
	
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, int param)
	{
		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valPtr = ptr->reverseY();
		if (!valPtr.isValid())
		{
			return;
		}
		
		bool val;
		valPtr.getValue(val);
		valPtr.setValue(!val);
	}

	// 导出属性参数
	// export property parameters
	virtual void writeCfg(Dahua::GenICam::ICameraPtr& camera, std::vector< XmlCfgItem >& itemVec)
	{
		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valPtr = ptr->reverseY();
		if (!valPtr.isValid())
		{
			return;
		}

		bool val;
		valPtr.getValue(val);

		XmlCfgItem item;
		item.name = getAttrName();

		std::stringstream ss;
		ss << val;
		item.value = ss.str();

		itemVec.push_back(item);
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "ReverseY";
	}

	// 更新属性参数
	// update property parameters
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, std::string const& strVal)
	{
		bool val;
		std::stringstream ss;
		ss << strVal;
		ss >> val;

		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valPtr = ptr->reverseY();
		if (!valPtr.isValid())
		{
			return;
		}

		valPtr.setValue(val);
	}

	CWnd* _wnd;
};

class CSoftTrigger : public IAttrCtrlBase
{
public:

	CSoftTrigger(CWnd* wnd)
		: _wnd(wnd)
	{}
	
	void init(Dahua::GenICam::ICameraPtr& camera) 
	{}

	// 更新自身的状态
	// Update own status
	virtual void updataStatus(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IImageFormatControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createImageFormatControl(camera);
		Dahua::GenICam::CBoolNode valuePtr = ptr->reverseY();
		if (!valuePtr.isValid())
		{
			return;
		}

		if (!valuePtr.isWriteable())
		{
			_wnd->GetDlgItem(IDC_BTN_SOFTTRIGGER)->EnableWindow(FALSE);
		}
		else
		{
			_wnd->GetDlgItem(IDC_BTN_SOFTTRIGGER)->EnableWindow(TRUE);
		}
	}
	
	virtual CWnd* getWnd()
	{
		return NULL;
	}
	
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, int param)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		Dahua::GenICam::CCmdNode cmd = ptr->triggerSoftware();
		if (!cmd.isWriteable())
		{
			return;
		}

		cmd.execute();
	}

	// 导出属性参数
	// export property parameters
	virtual void writeCfg(Dahua::GenICam::ICameraPtr& camera, std::vector< XmlCfgItem >& itemVec) {}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName() { return ""; }
	
	// 更新属性参数
	// update property parameters
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, std::string const& strVal) {}
	
	CWnd* _wnd;
};

class CMutiFrameEdit : public IAttrCtrlBase
{
public:

	CMutiFrameEdit(CWnd* wnd)
		: _wnd(wnd)
	{}

	void init(Dahua::GenICam::ICameraPtr& camera) 
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		Dahua::GenICam::CIntNode nodePtr = ptr->acquisitionFrameCount();
		if (!nodePtr.isWriteable())
		{
			_wnd->GetDlgItem(IDC_EDIT_FRAMENBR)->EnableWindow(FALSE);
			return;
		}
		
		int64_t val;
		nodePtr.getValue(val);
		
		_val = val;
		std::stringstream ss;
		ss << val;
		_wnd->GetDlgItem(IDC_EDIT_FRAMENBR)->SetWindowText( ss.str().c_str() );
	}
	
	// 更新自身的状态
	// Update own status
	virtual void updataStatus(Dahua::GenICam::ICameraPtr& camera)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		Dahua::GenICam::CIntNode valuePtr = ptr->acquisitionFrameCount();
		if (!valuePtr.isValid())
		{
			return;
		}
		
		if (!valuePtr.isWriteable())
		{
			_wnd->GetDlgItem(IDC_EDIT_FRAMENBR)->EnableWindow(FALSE);
		}
		else
		{
			_wnd->GetDlgItem(IDC_EDIT_FRAMENBR)->EnableWindow(TRUE);
		}
	}
	
	virtual CWnd* getWnd()
	{
		return _wnd->GetDlgItem(IDC_EDIT_FRAMENBR);
	}
	
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, int param)
	{
		int64_t val;
		::CString text;
		_wnd->GetDlgItem(IDC_EDIT_FRAMENBR)->GetWindowText(text);
		std::stringstream ss;
		ss << text;
		ss >> val;
		
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		Dahua::GenICam::CIntNode valuePtr = ptr->acquisitionFrameCount();
		if (!valuePtr.isValid())
		{
			return;
		}

		if (_val != val && valuePtr.isWriteable())
		{
			valuePtr.setValue(val);
			_val = val;
		}
		
		std::stringstream ss1;
		ss1 << _val;
		_wnd->GetDlgItem(IDC_EDIT_FRAMENBR)->SetWindowText(ss1.str().c_str());
	}

	// 导出属性参数
	// export property parameters
	virtual void writeCfg(Dahua::GenICam::ICameraPtr& camera, std::vector< XmlCfgItem >& itemVec)
	{
		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		Dahua::GenICam::CIntNode valuePtr = ptr->acquisitionFrameCount();
		if (!valuePtr.isValid())
		{
			return;
		}

		int64_t val;
		valuePtr.getValue(val);

		XmlCfgItem item;
		item.name = "AcquisitionFrameCount";

		std::stringstream ss;
		ss << val;
		item.value = ss.str();

		itemVec.push_back(item);
	}

	// 获取属性名称
	// get property name
	virtual std::string getAttrName()
	{
		return "AcquisitionFrameCount";
	}

	// 更新属性参数
	// update property parameters
	virtual void updataValue(Dahua::GenICam::ICameraPtr& camera, std::string const& strVal)
	{
		int64_t val;
		std::stringstream ss;
		ss << strVal;
		ss >> val;

		Dahua::GenICam::IAcquisitionControlPtr ptr = 
			Dahua::GenICam::CSystem::getInstance().createAcquisitionControl(camera);
		Dahua::GenICam::CIntNode valuePtr = ptr->acquisitionFrameCount();
		if (!valuePtr.isValid())
		{
			return;
		}
		
		valuePtr.setValue(val);
	}

	int64_t _val;
	CWnd*   _wnd;
};